#ifndef VSMORPHTREE_H
#define VSMORPHTREE_H
#include "VSController.h"
#include "VSModelMeshNode.h"
namespace VSEngine2
{
	class VSMorphBaseFunction;
	class VSMorphFunction;
	class VSMorphMainFunction;
	class VSStream;
	class VSGRAPHIC_API VSMorphTree : public VSController
	{
		//RTTI
		DECLARE_RTTI;
		//PRIORITY
		
	public:
		virtual ~VSMorphTree();
		virtual bool UpdateEx(double dAppTime);

		VSMorphTree(const VSUsedName &ShowName);
	protected:
		VSMorphTree();
	protected:

		VSArray<VSMorphBaseFunction *> m_pMorphFunctionArray;

		VSMorphMainFunction*  m_pMorphMainFunction;
	public:

		inline const VSMeshNode * GetMeshNode()const
		{
			return DynamicCast<VSModelMeshNode>(m_pObject);
		}

		void AddMorphFunction(VSMorphBaseFunction * pMorphFunction);
		void DeleteMorphFunction(VSMorphBaseFunction * pMorphFunction);
		inline VSMorphMainFunction * GetMorphMainFunction()const
		{
			return m_pMorphMainFunction;
		}
		virtual bool SetObject(VSObject * pObject);
	public:
		static bool RegisterMainFactory();
		
		virtual unsigned int DiskUse()const;

		virtual bool Save(VSStream & rStream,unsigned int &iSaveUse)const;
		virtual bool Load(VSStream & rStream,unsigned int &iSaveUse);
		virtual bool Link(VSStream & rStream);

		virtual bool Register(VSStream & rStream)const;
	private:
		static bool InitialClassFactory();	
		static VSObject * FactoryFunc();
		static bool ms_bRegisterMainFactory;
	public:
		virtual bool Clone(const VSObject *pObject,unsigned int uiType);

	};
	typedef VSPointer<VSMorphTree> VSMorphTreePtr;


}
#endif